﻿Imports DTO
Imports System.Data.OleDb

Public Class PhieuKhamBenhDAO
    'Public Sub Them(ByVal hsDto As KhamBenhDTO)
    '    Dim cn As OleDbConnection
    '    'B1 & B2: Tao chuoi ket noi, mo ket noi bang doi tuong ket noi
    '    cn = Data_Provider.ConnecDTB()
    '    'B3: Tao chuoi strSQL thao tac CSDL
    '    Dim strSQL As String
    '    strSQL = "Insert into HocSinh(Ten, NgaySinh, DiaChi, Toan, Ly, Hoa, DTB, MaLop) values (?, ?, ?, ?, ?, ?, ?, ?)"

    '    'B4: Thuc thi chuoi strSQL
    '    Dim cmd As New OleDbCommand(strSQL, cn)

    '    cmd.Parameters.Add("@HoTen", OleDbType.WChar)
    '    cmd.Parameters.Add("@NgaySinh", OleDbType.Date)
    '    cmd.Parameters.Add("@DiaChi", OleDbType.WChar)
    '    cmd.Parameters.Add("@GioiTinh", OleDbType.Date)

    '    'cmd.Parameters("@Ten").Value = hsDto.Ten
    '    'cmd.Parameters("@NgaySinh").Value = hsDto.NgaySinh
    '    'cmd.Parameters("@DiaChi").Value = hsDto.DiaChi
    '    'cmd.Parameters("@Toan").Value = hsDto.Toan
    '    'cmd.Parameters("@Ly").Value = hsDto.Ly
    '    'cmd.Parameters("@Hoa").Value = hsDto.Hoa
    '    'cmd.Parameters("@DTB").Value = hsDto.DTB
    '    'cmd.Parameters("@MaLop").Value = hsDto.MaLop

    '    cmd.ExecuteNonQuery()

    '    strSQL = "Select @@IDENTITY"
    '    cmd = New OleDbCommand(strSQL, cn)
    '    hsDto.MaBenhNhan = cmd.ExecuteScalar()
    '    'B5: Dong ket noi CSDL
    '    cn.Close()
    'End Sub

    Public Function layDSCN() As List(Of DTO.PhieuKhamBenhDTO)
        Dim sql As String
        sql = "select * From PHIEUKHAMBENH"
        Dim conn As OleDb.OleDbConnection = Data_Provider.ConnecDTB()
        Dim com As New OleDb.OleDbCommand(sql, conn)
        Dim reader As OleDb.OleDbDataReader = com.ExecuteReader()
        Dim ds As New List(Of DTO.PhieuKhamBenhDTO)
        While reader.Read()
            Dim conDTO As New DTO.PhieuKhamBenhDTO()
            conDTO.DuDoanLoaiBenh = reader.GetInt32(2)
            conDTO.TrieuChung = reader.GetString(1)
            ds.Add(conDTO)
        End While
        conn.Close()
        Return ds
    End Function
    Public Function LayMaTrieuChung() As List(Of DTO.TrieuChungDTO)
        Dim sql As String
        sql = "select * from TRIEUCHUNG"
        Dim conn As OleDb.OleDbConnection = Data_Provider.ConnecDTB()
        Dim com As New OleDb.OleDbCommand(sql, conn)
        Dim reader As OleDb.OleDbDataReader = com.ExecuteReader()
        Dim ds As New List(Of DTO.TrieuChungDTO)
        While reader.Read()
            Dim tcDTO As New DTO.TrieuChungDTO()
            tcDTO.MaTrieuChung = reader.GetInt32(2)
            ds.Add(tcDTO)
        End While
        conn.Close()
        Return ds
    End Function
    Public Function LayMaLoaibenh() As List(Of DTO.LoaiBenhDTO)
        Dim sql As String
        sql = "select * From LOAIBENH"
        Dim conn As OleDb.OleDbConnection = Data_Provider.ConnecDTB()
        Dim com As New OleDb.OleDbCommand(sql, conn)
        Dim reader As OleDb.OleDbDataReader = com.ExecuteReader()
        Dim ds As New List(Of DTO.LoaiBenhDTO)
        While reader.Read()
            Dim tcDTO As New DTO.LoaiBenhDTO()
            tcDTO.MaLoaiBenh = reader.GetInt32(2)
            ds.Add(tcDTO)
        End While
        conn.Close()
        Return ds
    End Function


End Class
